
// const DEFAULT_LOG = {
//   timestamp: 0,
//   version: '1.0',
//   operation: 'window'
// }

// const DEFAULT_ORDERLISTGETREQUEST = {
//   timestamp: 0,
//   version: '1.0',
//   operation: 'window',
//   pageSize: 10,
//   pageNum: 1,
//   time: '',
//   startTime: '',
//   endTime: '',
//   source: '',
//   state: '',
//   stayPerson: '',
//   orderNum: '',
//   search: ''
// }

export function getOrders (options) {
  return window.fetch({
    method: 'POST',
    url: '/order/all',
    data: options
  })
}
export function geSourceList(){
  return window.fetch({
    method: 'POST',
    url: '/order/sourcel',
  })
}
export function getOrder (orderId) {
  return window.fetch({
    method: 'POST',
    url: '/order/orderinfo',
    data: {
      orderId
    }
  })
}

export function getAddOrderInfo () {
  return window.fetch({
    method: 'POST',
    url: '/order/request',
    data: {}
  })
}
export function updateOrder (orderId, state, form) {
  return window.fetch({
    method: 'POST',
    url: '/order/update/state',
    data: {
      orderId,
      state,
      refunds: form.refunds || 0,
      remark: form.remark || ''
    }
  })
}

export function cancelOrder (orderId) {
  return window.fetch({
    method: 'POST',
    url: '/order/cancel',
    data: {
      orderId
    }
  })
}

export function transferOrder (orderId, transfer) {
  return window.fetch({
    method: 'POST',
    url: '/order/transfer',
    data: {
      orderId,
      transfer
    }
  })
}

export function updateReservationNum (orderId, bookingHotelNum) {
  return window.fetch({
    method: 'POST',
    url: '/order/update/hotelnum',
    data: {
      bookingHotelNum,
      orderId,
      orderParticularsRequest: Object.assign({}, DEFAULT_LOG, {
        orderId
      })
    }
  })
}

export function updateMark (orderId, remark) {
  return window.fetch({
    method: 'POST',
    url: '/order/update/remark',
    data: {
      orderId,
      remark,
      orderParticularsRequest: Object.assign({}, DEFAULT_LOG, {
        orderId
      })
    }
  })
}

export function getFinanceList (options) {
  return window.fetch({
    method: 'POST',
    url: '/finance/list',
    data: {
      pageSize: options.pageSize || 10,
      pageNum: options.pageNum || 1,
      state: parseInt(options.state) || -1,
      mode: options.mode || -1,
      search: options.search || -1
    }
  })
}

export function getFinanceDetail (id) {
  return window.fetch({
    method: 'POST',
    url: '/finance/flowing',
    data: {
      id
    }
  })
}

export function getFinancePayed (options) {
  return window.fetch({
    method: 'POST',
    url: '/clearing/closed/list',
    data: {
      pageSize: options.pageSize || 10,
      pageNum: options.pageNum || 1,
      hotelId: options.hotelId || -1,
      time: options.time || -1,
      startTime: options.startTime || '-1',
      endTime: options.endTime || '-1',
      mode: options.mode || -1,
      state: options.state || '-1',
      search: options.search || '-1'
    }
  })
}

export function getFinancePayedDetail (id) {
  return window.fetch({
    method: 'POST',
    url: '/clearing/closed/detail',
    data: {
      id
    }
  })
}

export function getClearingClosed (clearingId) {
  return window.fetch({
    method: 'POST',
    url: 'clearing/closed/batchrequest',
    data: {
      clearingId
    }
  })
}

export function ClearingClosed (options) {
  return window.fetch({
    method: 'POST',
    url: 'clearing/closed/handling',
    params: {
      token: window.commo.token
    },
    data: {
      clearingTotalPrice: options.clearingTotalPrice,
      clearingId: options.clearingId,
      closedObject: options.closedObject,
      clearingNum: options.clearingNum,
      payer: options.payer,
      payBanks: options.payBanks,
      banksAccount: options.banksAccount,
      arriveTime: options.arriveTime,
      closedMoney: options.closedMoney,
      flowing: options.flowing,
      remark: options.remark
    }
  })
}

export function getFinancePay (options) {
  console.log(options)
  return window.fetch({
    method: 'POST',
    url: '/clearing/pay/list',
    data: {
      pageSize: options.pageSize || 10,
      pageNum: options.pageNum || 1,
      hotelId: options.hotelId,
      time: options.timeData,
      startTime: options.startTime,
      endTime: options.endTime,
      mode: options.modeData,
      state: options.stateData,
      search: options.search
    }
  })
}

export function getFinancePayDetail (id) {
  return window.fetch({
    method: 'POST',
    url: '/clearing/pay/detail',
    data: {
      id
    }
  })
}

export function getClearingPay (clearingId) {
  return window.fetch({
    method: 'POST',
    url: 'clearing/pay/batchrequest',
    data: {
      clearingId
    }
  })
}

export function ClearingPay (options) {
  return window.fetch({
    method: 'POST',
    url: 'clearing/pay/handling',
    params: {
      token: window.commo.token
    },
    data: {
      clearingTotalPrice: options.clearingTotalPrice,
      clearingId: options.clearingId,
      closedObject: options.closedObject,
      clearingNum: options.clearingNum,
      payer: options.payer,
      payBanks: options.payBanks,
      banksAccount: options.banksAccount,
      arriveTime: options.arriveTime,
      closedMoney: options.closedMoney,
      flowing: options.flowing,
      remark: options.remark
    }
  })
}

export function getMoney (options, number) {
  return window.fetch({
    method: 'POST',
    url: '/order/getmoney',
    data: {
      liveDate: options.liveTime || null,
      leaveDate: options.leaveTime || null,
      roomId: options.bookingSellingRoom || null,
      number: number
    }
  })
}

export function roomState (options) {
  return window.fetch({
    method: 'POST',
    url: '/order/roomstate',
    data: {
      liveTime: options.liveTime || null,
      leaveTime: options.leaveTime || null,
      saleRoom: options.bookingSellingRoom || null
    }
  })
}

export function roomNum (options) {
  return window.fetch({
    method: 'POST',
    url: '/order/roomnum',
    data: {
      liveTime: options.liveTime || null,
      leaveTime: options.leaveTime || null,
      saleRoom: options.bookingSellingRoom || null
    }
  })
}

//  新增订单房价信息（new）/order/request/prices

export function getPrices (options) {
  return window.fetch({
    method: 'POST',
    url: '/order/request/prices',
    data: options
  })
}
// 查看订单详情 
export function getOrderDetail (id) {
  return window.fetch({
    method: 'POST',
    url: '/order/orderinfo',
    data: id
  })
}
//  新增订单基础信息
export function getOrderBaseInfo (option) {
  return window.fetch({
    method: 'POST',
    url: '/order/request/base',
    data: option
  })
}

//  新增订单 /order/addnew
export function addOrder (option) {
  return window.fetch({
    method: 'POST',
    url: '/order/addnew',
    data: option
  })
}



export function getOrderStateList (data) {
  return window.fetch({
    method: 'POST',
    url: '/order/data',
    data:data
  })
}